package com.huabo.system.oracle.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huabo.system.oracle.entity.*;
import com.huabo.system.page.PageBean;
import com.hbfk.util.PageInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

public interface ProcessSettingMapper extends BaseMapper<ProcessSetting> {

    @SelectProvider(type=ProcessSettingMapperSqlConfig.class,method="selectListByPageInfo")
    List<ProcessSetting> selectListByPageInfo(PageInfo<ProcessSetting> pageInfo, BigDecimal orgid, BigDecimal companyid);

//    @Select("SELECT * FROM TBL_PROCESS_SETTING WHERE ORGID = #{orgid}")
//    PageBean selectOrgid(BigDecimal orgid);

    @Select("SELECT COUNT(*) from TBL_PROCESS_SETTING t where COMPANYID= #{companyid} or ORGID=#{orgid}")
    Integer selectCountByPageInfo(PageInfo<ProcessSetting> pageInfo, BigDecimal orgid, BigDecimal companyid);

    @SelectProvider(method="selctOrgid",type=ProcessSettingMapperSqlConfig.class)
    @Results({
            @Result(column="ORGNAME",property="tblOrganization.orgname")
    })
    List<ProcessSetting> selctOrgid(PageInfo<ProcessSetting> pageInfo,BigDecimal orgid);

    //@SelectProvider(method="select",type=ProcessSettingMapperSqlConfig.class)
    @Select("SELECT COUNT(*) from TBL_PROCESS_SETTING WHERE COMPANYID = #{orgid} ")
    Integer select(BigDecimal orgid);

    @Select("SELECT * FROM TBL_PROCESS_SETTING WHERE SETTINGID = #{settingid}")
    ProcessSetting selectBySettingId(BigDecimal settingid);

    @UpdateProvider(type=ProcessSettingMapperSqlConfig.class,method="updateByProcessSetting")
    void updateByProcessSetting(ProcessSetting processSetting);

    @InsertProvider(type=ProcessSettingMapperSqlConfig.class,method="savemerge")
    void savemerge(ProcessSetting setting);

    @Delete("DELETE FROM TBL_PROCESS_SETTING WHERE SETTINGID = #{settingId}")
    void deleteBySettingId(BigDecimal settingId);

    @Select("SELECT * from TBL_PROCESS_SETTING t where t.module = #{definitionName}  order by SETTINGID desc")
    List<ProcessSetting> getByModuel(String definitionName);

    @Select("SELECT * from TBL_PROCESS_SETTING WHERE SETTINGID = #{tid}")
    List<String> getButtonsForTransition(String tid);

}
